package com.gsafety.wellsfort.domain.dto.question;

import com.gsafety.wellsfort.domain.model.knowledge.AnswerOption;
import com.gsafety.wellsfort.domain.model.knowledge.Question;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@Data
public class QuestionDTO {
    @ApiModelProperty(value = "题目id",required = false)
    private Integer id;

    @ApiModelProperty(value = "试题对象",required = true)
    @NotEmpty
    private Integer objectType;

    @ApiModelProperty(value = "关键字",required = true)
    private String keyword;

    @ApiModelProperty(value = "题目类型",required = true)
    @NotEmpty
    private Integer questionType;

    @ApiModelProperty(value = "题目文字",required = true)
    @NotEmpty
    private String questionTitle;

    @ApiModelProperty(value = "答案解析")
    private String analyzing;


    @ApiModelProperty(value = "题目选项数组",required = false)
    private List<AnswerOption> answerOptionList;

    public static  class POBuilder{
        Question q =new Question();
        QuestionDTO qVo;
        public POBuilder(QuestionDTO qVo){
            this.qVo=qVo;
        }
        public Question build(){
            BeanUtils.copyProperties(qVo,q);
            q.setExamType(qVo.questionType);
            q.setTitle(qVo.questionTitle);
            return q;
        }
    }
}
